<script type="text/javascript"><!--//--><![CDATA[//><!--
    $(document).ready(function() {
        // Setup Form
        $('#form_popup').setupForm([
            { name: 'user_id', type: 'text', size: 'short', maxlength: 40, noempty: true },
            { name: 'user_password', type: 'password', size: 'long', maxlength: 225, noempty: true},
			{ name: 'nip', type: 'lov', size: 'medium',
				onClearButton:function(){
					$(this).setval(''); 
					$('#person_id, #user_name, #email, #department_code').setval(''); 
				},
				onActionButton:function(){ 
					LOVperson({ onSelect:function(row){ 
						$('#person_id').setval(row.person_id); 
						$('#nip').setval(row.nip); 
						$('#user_name').setval(row.full_name); 
						$('#email').setval(row.email); 
						$('#department_code').setval(row.department_code); 
					}, param : '?no_user=1' }); 
				}
			},
			{ name: 'person_id', type: 'text' },
            { name: 'user_name', type: 'text', size: 'long', maxlength:100, noempty: true },
            { name: 'description', type: 'text', size: 'long', maxlength: 225 },
            { name: 'email', type: 'text', size: 'medium', maxlength:60 },
			<?php /*
			{ name: 'department_code', size: 'medium', data:<?php echo json_encode(array_merge(array(array('value'=>'','display'=>'')), $combo_departement)); ?> },
            { name: 'culture_id', data:<?php echo json_encode($combo_culture); ?>, size: 'medium'},
			*/ ?>
            { name: 'status', data:[ {value:'1', display:'Aktif'}, {value:'0',display:'Non Aktif'} ], size: 'short' },
			{ name: 'readonly_role', type: 'text', size: 'medium', maxlength:60 }
        ], <?php echo json_encode($data); ?>);
        
        <?php if($mode=="edit"){ ?>
        $('#user_id').readonly();
        //$('#user_password').setTooltips('kosongkan jika tidak ingin merubah user_password');
        $('#user_password').after('<div style="font-size:9px;">kosongkan jika tidak ingin merubah user_password</div>');
        <?php } ?>
        
		$('#person_id').hide();
		$('#culture_id').readonly();
		
		
		$('#tt').tabs({  
			border:false,
			onSelect:function(title){  
					return false;
			}  
		});  

        // Focus at First Object
		$('#form_popup').focusFirst();
		
		<?php if($readonly_role){ ?>
			$('#department_code').readonly();
			$('#status').readonly();        
	    <?php } ?>
    });
//--><!]]></script>

<div id="tt" class="easyui-tabs" style="width:550px;height:380px;">  
    <div title="Data User" style="padding:10px;">
    	<div id="form_popup_message" style="display:none;"></div>
        <table class="tb_form" style="display:none;" cellpadding="0" cellspacing="0">
        <tr>
            <td class="label">User ID</td>
            <td><input id="user_id" /></td>
        </tr>
        <tr>
            <td class="label">Password</td>
            <td><input id="user_password" /></td>
        </tr>
        <tr style="display:none;">
        	<td class="label">ID Card Number (NIK)</td>
            <td><input id="person_id" /> <input id="nip" /></td>
        </tr>
        <tr>
            <td class="label">Nama User</td>
            <td><input id="user_name" /></td>
        </tr>
        <tr>
            <td class="label">Deskripsi</td>
            <td><input id="description" /></td>
        </tr>
        <tr>
            <td class="label">Email</td>
            <td><input id="email" /></td>
        </tr><?php /*
        <tr>
            <td class="label">Departement</td>
            <td><input id="department_code" /></td>
        </tr>
        <tr>
            <td class="label">Regional Setting</td>
            <td><input id="culture_id" /></td>
        </tr>*/ ?>
        <tr>
            <td class="label">Status</td>
            <td><input id="status" /></td>
        </tr>
		
		<tr style="display:none;">
            <td class="label">Status</td>
            <td><input id="readonly_role" /></td>
        </tr>
        </table>
    </div>  
	<?php if (!$readonly_role) { ?>
	<div title="User Role Detail" style="overflow:auto;padding:10px;">  
        <?php
			if(count($arr_role) > 0){
				$last_app_id = '';
				for($i=0,$max_i=count($arr_role); $i<$max_i; $i++){
					$row = $arr_role[$i];
					if($last_app_id != $row['app_id']){
						if($i>0){
							echo '<br clear="all" /><br />';
							$last_app_id = $row['app_id'];
						}
						echo '<div style="font-weight:bold;">' . $row['app_name'] . '</div>';
					}
					echo	'<label style="width:250px;display:inline-block;">'.
								'<input onclick="'.($readonly_role? 'return false;' : '').'" type="checkbox" name="role_' . htmlspecialchars($row['role_id']) . '" '.($row['checked']=='1' ? 'checked="checked" ' : '').'/> ' . 
								htmlentities($row['role_name']) . 
							'</label>';
				}
			}
		?>
    </div>
	<?php } ?>
</div>
